package ProjetCorba.Code;

import java.util.ArrayList;

/**
 * Code serveur de la gestion des tarifs
 * @author Mathieu
 *
 */
public class ServeurBanque{

	/**
	 * 
	 * Main de banque
	 * @param args
	 * 
	 */
	public static void main (String args[]) {
		ServeurBanque seb = new ServeurBanque();


		ArrayList<Region> lesRegions;

		String nom = "Banque";
		String liste_obj;
		short altitude;
		short angle;
		boolean sens;

		lesRegions = Region.chargerRegion();
		try{
			// 1
			org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,null);

			// Recuperation NS + POA
			org.omg.CosNaming.NamingContext nameRoot = org.omg.CosNaming.NamingContextHelper.narrow(orb.resolve_initial_references("NameService"));
			org.omg.PortableServer.POA rootPOA = org.omg.PortableServer.POAHelper.narrow(orb.resolve_initial_references("RootPOA"));

			// 3
			GestionTarifImpl maBanque = new GestionTarifImpl(lesRegions);

			// 4
			rootPOA.activate_object(maBanque);

			// 5
			rootPOA.the_POAManager().activate();

			// 6
			System.out.println(orb.object_to_string(rootPOA.servant_to_reference(maBanque)));

			org.omg.CosNaming.NameComponent[] nameToRegister = new org.omg.CosNaming.NameComponent[1];

			nameToRegister[0] = new org.omg.CosNaming.NameComponent(nom,"");
			nameRoot.rebind(nameToRegister, rootPOA.servant_to_reference(maBanque));

			System.out.println("bla : " + nom);
			// 7
			orb.run();
		} catch (Exception e) {e.printStackTrace();}
	}

}
